const store = require('../storage')
const baseUrl = store.get().baseUrl || "https://jiankangpao.sichuancancer.org/azfzjkp";

exports.baseUrl = baseUrl
require('./login')
require('./request')
require('./decorator')
const request = require("miniapp-request");

//获取检查更新的实例
const updater = require('../wxupdate')

const updaterInstance = updater({
    interval: 60 * 1000, //一分钟检查一次
    onUpdateReady() {
        this.stop()
        wx.showModal({
            title: '小程序更新',
            content: '现有新的版本更新已经准备好，重启小程序将能体验最新功能。',
            confirmText: '现在更新',
            cancelText: '稍后提醒',
            success: (res) => {
                //停止检查并
                if (res.confirm) {

                    this.applyUpdate()
                } else if (res.cancel) {
                    //推迟5分钟提示
                    setTimeout(() => {
                        this.start()
                    }, 60 * 1000 * 4);
                }

            },

        })
    }
})

//开始检查
updaterInstance.start()

exports = {
    baseUrl
}